package main.java.name.fowler.refactoring.simplestore;

import java.util.List;

public class Reporter {
	public static String statement(Customer customer)
	{
		double totalAmount = 0;
        int frequentRenterPoints = 0;
        
        String result = "Rental record for " + customer.getM_Name() + "\n"; 

        List<Rental> m_Rentals = customer.getRentals();

        for(Rental each: m_Rentals) {
            double thisAmount = each.getPriceCode();

            // Add frequent renter points
            frequentRenterPoints += each.getFrequentRenterPoints();


            // Show figures for this rental
            result += "\t" + each.getM_Movie().getM_Title() + "\t" + thisAmount + "\n";
            totalAmount += thisAmount;
        }

        // Add footer lines
        result += "Amount owed is " + totalAmount + "\n";
        result += "You earned " + frequentRenterPoints + " frequent renter points.";
        return result;
    }
}
